import { defineStore } from "pinia"
import { ref } from "vue"
import type { PromotionalItem } from "@/types/promotional"

export const usePromotionalStore = defineStore("promotional", () => {
    const _promotional: PromotionalItem[] = [
        {
            id: 1,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 2,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 3,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 4,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 5,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 6,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 7,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 8,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 9,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 10,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 11,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 12,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 13,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 14,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 15,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 16,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 17,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 18,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 19,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 20,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 21,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 22,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 23,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 24,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 25,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 26,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 27,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 28,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 29,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 30,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 31,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 32,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 33,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 34,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 35,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 36,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
        {
            id: 37,
            title: "深圳 & 高中英语直通票",
            cover:
                "https://bpic.588ku.com/templet_pic/21/06/08/b1f980b852add5eb43303a303b5329b7.jpg!/fw/750/quality/90/unsharp/true/compress/true",
            price: 173,
            area: "中国",
        },
    ]

    const promotionalList = ref<PromotionalItem[]>([])

    // 模拟异步请求
    const getPromotionalList = (page: number, size: number) => {
        return new Promise<{
            data: PromotionalItem[]
            page: number
            total: number
            hasMore: boolean
        }>((resolve) => {
            setTimeout(() => {
                const data = _promotional.slice((page - 1) * size, page * size)
                promotionalList.value = [...promotionalList.value, ...data]
                resolve({
                    data,
                    page,
                    total: _promotional.length,
                    hasMore: page * size < _promotional.length,
                })
            }, 100)
        })
    }

    return {
        promotionalList,
        getPromotionalList,
    }
})
